<template>
	<view class="">
		<nav-bar title="地址添加"></nav-bar>
		<van-address-edit :area-list="areaList" show-set-default
			:area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave" />

	</view>
</template>

<script>
	
	import { areaList } from '@vant/area-data';
	const Address = uniCloud.importObject("address");
	import Storage from '@/untils/storage.js'
	export default {
		setup() {
			return {
				areaList,
			};
		},
		methods:{
			onSave(e){
				Address.add({
					user_id:Storage.userinfo._id,
					name:e.name,
					tel:e.tel,
					province:e.province,
					city:e.city,
					area:e.county,
					areaCode:e.areaCode,
					detail:e.addressDetail,
					is_default:e.isDefault
				}).then(res=>{
					if(res.id){
						uni.showToast({
							title:"添加成功"
						})
					}else{
						uni.showToast({
							title:"添加失败",
							icon:"error"
						})
					}
					console.log(res);
				})
				console.log(e);
			}
		}
	};
</script>

<style>
</style>
